<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>โปรแกรมโพส Amazon ลง Blogger version 2.0</title>
        <!-- jQuery -->
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
        <!-- markItUp! -->
        <script type="text/javascript" src="markitup/jquery.markitup.js"></script>
        <!-- markItUp! toolbar settings -->
        <script type="text/javascript" src="markitup/sets/default/set.js"></script>
        <!-- markItUp! skin -->
        <link rel="stylesheet" type="text/css" href="markitup/skins/markitup/style.css" />
        <!--  markItUp! toolbar skin -->
        <link rel="stylesheet" type="text/css" href="markitup/sets/default/style.css" />
    </head>
    <body>
        <script type="text/javascript">
            <!--
            $(document).ready(function()	{
                // Add markItUp! to your textarea in one line
                // $('textarea').markItUp( { Settings }, { OptionalExtraSettings } );
                $('#markItUp').markItUp(mySettings);

                // You can add content from anywhere in your page
                // $.markItUp( { Settings } );
                $('.add').click(function() {
                    $.markItUp( { 	openWith:'<opening tag>',
                        closeWith:'<\/closing tag>',
                        placeHolder:"New content"
                    }
                );
                    return false;
                });

                // And you can add/remove markItUp! whenever you want
                // $(textarea).markItUpRemove();
                $('.toggle').click(function() {
                    if ($("#markItUp.markItUpEditor").length === 1) {
                        $("#markItUp").markItUpRemove();
                        $("span", this).text("get markItUp! back");
                    } else {
                        $('#markItUp').markItUp(mySettings);
                        $("span", this).text("remove markItUp!");
                    }
                    return false;
                });
            });
            -->
        </script>

        <h1>ตั้งค่า Template</h1>
        <?php

        $config = @simplexml_load_file("template.xml");
        if(isset($_POST['submit'])) {
            $title = $_POST['title'];
            $content = $_POST['markItUp'];
            $title = stripslashes($title);
            $content = stripslashes($content);
            $title = base64_encode($title);
            $content = base64_encode($content);

            $xml = file_get_contents("template.xml");
            $xml = str_replace("<title>".$config->title."</title>","<title>".$title."</title>",$xml);
            $xml = str_replace("<content>".$config->content."</content>","<content>".$content."</content>",$xml);
            if(@file_put_contents("template.xml",$xml)) echo '<div style="color:green">***บันทึกข้อมูลเรียบร้อย***</div>';
        }
        if(isset($_POST['default'])) {
            $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
                   <config>
                        <title>e2tleXdvcmR9Ont0aXRsZX0=</title>
                        <content>PGRpdiBzdHlsZT0iY2xlYXI6IGJvdGg7IHRleHQtYWxpZ246IGNlbnRlcjsiPg0KPGEgaHJlZj0ie3VybH0iIHRpdGxlPSJTZWV7dGl0bGV9IERldGFpbHMiPiANCjxpbWcgc3JjPSJ7bGFyZ2VpbWFnZX0iIGFsdD0ie3RpdGxlfSIgd2lkdGg9IjMwMHB4IiAvPjwvYT4gDQo8L2Rpdj4gDQo8ZGl2PjxzdHJvbmc+Q3VzdG9tZXIgUmF0aW5nPC9zdHJvbmc+IDogPGRpdj57cmF0aW5nfTwvZGl2PiANCjxzdHJvbmc+TGlzdCBQcmljZTwvc3Ryb25nPiA6IDxzcGFuIHN0eWxlPSJ0ZXh0LWRlY29yYXRpb246bGluZS10aHJvdWdoOyI+e2xpc3RwcmljZX08L3NwYW4+IDxzdHJvbmc+UHJpY2U8L3N0cm9uZz4gOiA8c3BhbiBzdHlsZT0iY29sb3I6I2U4MDAwMDtmb250LXNpemU6MS4zZW07Zm9udC13ZWlnaHQ6Ym9sZDsiPntwcmljZX08L3NwYW4+IA0KPGEgaHJlZj0ie3VybH0iIHRpdGxlPSJ7dGl0bGV9Ij48aW1nIHNyYz0ie2Z1bGxyZXZpZXdzfSIgYWx0PSJ7dGl0bGV9IiAvPjwvYT4NCjwvZGl2PiANCntjb250ZW50fQ0Ke2ZlYXR1cmVzfQ0KPGRpdiBzdHlsZT0iY2xlYXI6IGJvdGg7IHRleHQtYWxpZ246IGNlbnRlcjsiPiANCjxhIGhyZWY9Int1cmx9IiB0aXRsZT0iQ2hlY2sgZm9yIExvd2VzdCBQcmljZXMge3RpdGxlfSIgcmVsPSJub2ZvbGxvdyI+IDxpbWcgc3JjPSJ7bG93cHJpY2V9IiBhbHQ9Int0aXRsZX0iIC8+PC9hPg0KPC9kaXY+</content>
                   </config>";

            if(@file_put_contents("template.xml",$xml)) echo '<div style="color:green">***ค่า Default Template ***</div>';
        }

        $config = @simplexml_load_file("template.xml");
        ?>

        <fieldset>
            <form action="#" method="post" >
                <input type="hidden" id="hidden" name="hidden" value="Y" />
                
                    <table width="300px">
                        <tr>
                            <td><fieldset><legend>Tag Available</legend>
                                {title} , {keyword} , {url},{features} ,
                                {thumbnail} , {rating} , {buynow} , {lowprice} ,
                                {listprice} , {price}, {smallimage}, {content},
                                {mediumimage}, {largeimage}  ,{reviews} </fieldset></td>
                        </tr>
                    </table>
                
                <table>
                    <tr>
                        <td>Title :</td>
                        <td><input type="text" id="title" name="title" size="100" value="<?=base64_decode($config->title)?>" /></td>
                    </tr>
                    <tr>
                        <td>Content :</td>
                        <td><textarea id="markItUp" name="markItUp" cols="80" rows="20"><?=base64_decode($config->content)?></textarea></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><input type="submit" name="submit" value="บันทึก Template" />
                            <input type="submit" name="default" value="Default Template" />
                        </td>
                    </tr>
                </table>
            </form>
        </fieldset>
        <a href="index.php">กลับหน้าหลัก</a>
    </body>
</html>
